#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

char shift(char c){
    if('a'<=c && c<='z'){
      return (c-'a')+'A';
    }
    else{
      return (c-'A')+'a';
    }
  }

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
    string s;
    cin >> s;
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        if(i){cout << " ";}
        ll k;
        cin >> k;
        k--;
        ll th=k/s.size();
        ll offset=k%s.size();
        if(__builtin_popcountll(th)%2){
            cout << shift(s[offset]);
        }
        else{
            cout << s[offset];
        }
    }cout << endl;
  

    return 0;
}